﻿using BCCommon;
using BCDto.TMS.MarketingCoupon.MarketingCoupon;
using BCService.TMS.MarketingCoupon.MarketingCoupon;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.Management.TMS.MarketingCoupon
{
    /// <summary>
    /// 优惠券
    /// </summary>
    [Route("api/v1/sim/[controller]")]
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    public class MarketingCouponController : ManagementBaseController
    {
        private readonly IMarketingCouponService marketingCouponService;

        public MarketingCouponController(IMarketingCouponService marketingCouponService)
        {
            this.marketingCouponService = marketingCouponService;
        }


        /// <summary>
        /// 获取优惠券的总数量
        /// </summary>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(MarketingCouponCountDto), 200)]
        public IActionResult GetAllCount()
        {
            var result = this.marketingCouponService.GetAllCount(this.Admin);
            return this.Ok(result);
        }
        /// <summary>
        /// 获取优惠券信息
        /// </summary>
        /// <param name="marketingCouponId">优惠券id</param>
        /// <returns></returns>
        [HttpGet("{marketing_coupon_id}")]
        [ProducesResponseType(typeof(MarketingCouponDto), 200)]
        public IActionResult GetSingle([FromRoute(Name = "marketing_coupon_id")] long marketingCouponId)
        {
            var result = this.marketingCouponService.GetSingle(marketingCouponId);
            return this.Ok(result);
        }

        /// <summary>
        /// 获取优惠券分页
        /// </summary>
        /// <param name="marketingCouponTypeId">优惠券类型id</param>
        /// <param name="isReceive">是否领取</param>
        /// <param name="isUse">是否使用</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet("[action]/{marketing_coupon_type_id}")]
        [ProducesResponseType(typeof(PageableList<MarketingCouponDto>), 200)]
        public IActionResult Query([FromRoute(Name = "marketing_coupon_type_id")] long marketingCouponTypeId,
            [FromQuery(Name = "is_receive")] bool? isReceive,
            [FromQuery(Name = "is_use")] bool? isUse,
            [FromQuery(Name = "page_index")] int pageIndex = 1,
            [FromQuery(Name = "page_size")] int pageSize = 10)
        {
            var result = this.marketingCouponService.Query(marketingCouponTypeId, isReceive, isUse, pageIndex, pageSize);
            return this.Ok(result);
        }
    }
}
